//全局公共方法


//深度复制对象
function cloneObjectFn(obj) {
  return JSON.parse(JSON.stringify(obj))
}

function sayHello(name) {
  console.log(`Hello ${name} !`)
}



 



function formatTime(date) {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
}



function formatDate(date) {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

   return [year,month,day].map(formatNumber).join('-')
}


const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : `0${n}`
}


var util={
  cloneObjectFn,
  sayHello,
  formatTime,
  formatDate,
}







//导出设置
export default util

// exports.cloneObjectFn = cloneObjectFn
// exports.sayHello = sayHello